package com.qianfeng.zhangwei.day28.utils;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

import java.io.IOException;
import java.io.InputStream;

/**
 * @说 明：
 * @项目名称：Sz1504
 * @包 名： com.qianfeng.zhangwei.day28.utils
 * @类 名： HttpUtils
 * @创 建人： zhangwei
 * @创建时间：2015-07-23 10:38
 * @版 本：v1.0
 * @修 改人：
 * @修改时间：
 * @修改备注：
 */
public class HttpUtils {
    public static Bitmap getBitmap(String url) {
        HttpClient httpClient = new DefaultHttpClient();
        Bitmap bitmap = null;
        HttpGet get = new HttpGet(url);
        try {
            HttpResponse httpResponse = httpClient.execute(get);
            if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                HttpEntity entity = httpResponse.getEntity();
                InputStream inputStream = entity.getContent();
                bitmap = BitmapFactory.decodeStream(inputStream);
            }


        } catch (IOException e) {
            e.printStackTrace();
        }
        return bitmap;

    }


}
